<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>login_required (LoginSystem)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/login_system.rb, line 43</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">login_required</span>
    
    <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">protect?</span>(<span class="ruby-identifier">action_name</span>)
      <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>  
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@session</span>[<span class="ruby-value str">'user'</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">authorize?</span>(<span class="ruby-ivar">@session</span>[<span class="ruby-value str">'user'</span>])
      <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-comment cmt"># store current location so that we can </span>
    <span class="ruby-comment cmt"># come back after the user logged in</span>
    <span class="ruby-identifier">store_location</span>
  
    <span class="ruby-comment cmt"># call overwriteable reaction to unauthorized access</span>
    <span class="ruby-identifier">access_denied</span>
    <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> 
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>